﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace JRBase
{
    public class PicSprite : Sprite
    {
        private float scale;
        private Rectangle destinationRect = new Rectangle();

        public void Initialize(Texture2D texture, Vector2 position, float scale)
        {
            base.active = true;
            base.texture = texture;
            base.position = position;
            base.width = texture.Width;
            base.height = texture.Height;
            this.scale = scale;
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            if (base.active)
            {
                spriteBatch.Draw(base.texture, destinationRect, Color.White);
            }
        }

        public override void Update(GameTime gameTime)
        {
            destinationRect = new Rectangle((int)position.X - (int)(base.width * scale) / 2,
                                            (int)position.Y - (int)(base.height * scale) / 2,
                                            (int)(base.width * scale),
                                            (int)(base.height * scale));
        }
    }
}
